<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1>c.html</h1>
  <!--  
GET /users HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7,ar;q=0.6
Connection: keep-alive
Cookie: username=jack; age=20
Host: 127.0.0.1:3001
Referer: http://127.0.0.1:3001/c.html
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"


  -->
  <button onclick="save()">save</button>
  <button onclick="read()">read</button>
  <button onclick="getUsers()">Ajx</button>
  <script>
    function getUsers() {
      const xhr = new XMLHttpRequest();
      xhr.open('GET', '/users');
      xhr.onload = function () {
        console.log(xhr.response);
      };
      xhr.send();
    }
    function save() {
      document.cookie = "username=jack";
      document.cookie = "age=20";
    }

    function read() {
      console.log(document.cookie);  // username=jack; age=20
    }
  </script>
</body>

</html>